package com.vip.elastic.dao;

import com.vip.elastic.entity.DocumentBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

/**
 * ElasticRepository
 *
 * @author wgb
 * @date 2020/11/10 10:41
 */
public interface ElasticRepository extends ElasticsearchRepository<DocumentBean, Long> {
    //默认的注释
    @Query("{\"bool\":{\"must\":[{\"term\":{\"content\": \"?0\"}}")
    Page<DocumentBean> findByContent(String content,Pageable pageable);

    @Query("{\"bool\" : {\"must\" : {\"field\" : {\"firstCode.keyword\" : \"?\"}}}}")
    Page<DocumentBean> findByFirstCode(String firstCode, Pageable pageable);

    @Query("{\"bool\" : {\"must\" : {\"field\" : {\"secordCode.keyword\" : \"?\"}}}}")
    Page<DocumentBean> findBySecordCode(String secordCode, Pageable pageable);
}
